<%@page import="com.kavitha.db.dataobject.Employee"%>
<%@page import="java.util.List"%>
<%@page import="com.kavitha.db.util.EmployeeUtil"%>
<%@page import="com.kavitha.db.util.PersistenceManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="com.mysql.jdbc.Driver"%>
<html>
<label>Employee Details</label>
<body>
	<%
if(request.getParameter("edit")!=null){
	EmployeeUtil.updateEmployee(request);
}

List<Employee> list =EmployeeUtil.getEmployeeDetails();

if(list!=null){
	%>
	<table border="1">
	<tr>
		<td>S.No</td>
		<td>FirstName</td> 
		<td>LastName</td>
		<td>Email Id</td>
		<td>Mobile No</td>
		<td>DOB</td>
		<td>Edit</td>
		<td>Delete</td>
	</tr>
	<%
	int i =1;
		for(int j=0;j<list.size();j++){
			Employee e = list.get(j);
			int id = e.getId();
		%>
		<tr>
			<td><%=i%></td>
			<td><%=e.getFirstName()      %></td>
			<td><%=e.getLastName()%></td>
			<td><%=e.getEmailId() %></td>
			<td><%=e.getPhoneNo() %></td>
			<td><%=e.getDob()%></td>
			<td><a href="edit.jsp?id=<%=id%>">edit</a></td>
			<td><a href="delete.jsp?id=<%=id%>">delete</a></td>
		</tr>
		<%
		i++;
	}
	%>
	</table>
	
<%	
}
%>
</body>
</html>
